// pages/customerDetailInfo/com/customer-header/customer-header.js
import p from '../../../../utils/platform';
import api from "../../../../common/api.js";
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    content: {
      type: Object,
      value: {}
    },
    analyzeContent: {
      type: Object,
      value: {}
    }
  },

  options: {
    styleIsolation: 'apply-shared',
    addGlobalClass: true,
  },

  /**
   * 组件的初始数据
   */
  data: {
    copyShowDialog: false
  },

  /**
   * 组件的方法列表
   */
  methods: {
    handleShield() {
      p.showModal({
          content: '屏蔽该访客后，将不再会看到该客户的访问记录以及客户分析数据',
        })
        .then((res) => {
          if (res.confirm) {
            api.setShiseldVisitor({
              userId: this.data.content.id,
              unionid: this.data.content.unionid
            }, (res) => {
              if (res.data.isSuccess) {
                p.showToast({
                  title: "屏蔽成功",
                  icon: "success",
                })

                setTimeout(() => {
                  p.navigateBack()
                }, 1500)


              } else {
                p.showToast({
                  title: "屏蔽失败",
                  icon: "error",
                })
              }
            })
          }
        })
    },
    handlePhone() {
      console.log(this.data.content.mobile);
      p.showModal({
          content: `拨号${this.data.content.mobile}`
        })
        .then((res) => {
          if (res.confirm) {
            p.makePhoneCall({
              phoneNumber: String(this.data.content.mobile)
            })
            
          }
        })
    },

    toggleCopyShowDialog() {
      var that = this;
      that.setData({
        copyShowDialog: false
      })
    },

    copyNickname: function(e) {
      var that = this;
      let nickNames = this.data.content.nickname;

      that.setData({
        copyShowDialog: true
      })
      wx.hideToast();
      wx.setClipboardData({
        data: nickNames,
        success(res) {
          wx.hideToast();
        }
      })
    },
  }
})